This function calculates a moving arithmetic mean from LReal values.
The method can be used to smooth data series; the values can be read in cyclically or triggered.
| LGF_SimpleAveraging (FB) | ||||||||
|---|---|---|---|---|---|---|---|---|
| Bool | cyclicExecution | average | LReal | |||||
| Bool | trigger | overflow | Bool | |||||
| Bool | reset | |||||||
| LReal | value | |||||||
| USInt | windowSize | |||||||
| Identifier | Data type | Default value | Description |
|---|---|---|---|
| cyclicExecution | Bool | FALSE | TRUE: cyclic operation, trigger not in use |
| trigger | Bool | FALSE | Rising edge: Read in `value` with every pulse at input `trigger` |
| reset | Bool | FALSE | TRUE: The block is reset and the calculation starts again. |
| value | LReal | 0.0 | Value/s from which the moving average is to be determined. |
| windowSize | USInt | 5 | Window length for averaging in the range from 1..255 |
| Identifier | Data type | Description |
|---|---|---|
| average | LReal | Moving / Floating average |
| overflow | Bool | TRUE: Overflow detected in the calculation |
LGF_SimpleAveraging does not query the data type for the input parameter value. For data types other than LReal, either an implicit conversion is performed automatically or an error is generated during compilation.The block calculates the (moving) average based on the set windowSize. If windowSize is set to windowSize < 1, the value is passed through without averaging.
There are two options for reading the values:
cyclicExecution input, the values are read and calculated cyclically.Trigger input, the values are read and calculated with each pulse.If the calculation reaches the value range limits of LReal, the output overflow is set.
| Version & Date | Change description | |
|---|---|---|
| 1.0.0 | Simatic Systems Support | |
| 18.07.2024 | First Release | |